package lab_4;

import java.util.Properties;
import javax.naming.InitialContext;
import javax.naming.NamingException;

/**
 *
 * @author grp02 - Pascal Charreix and Meike Paetz
 *
 * This is the SmartTours client using the remote object
 */
public class SmartToursClient {

    private SmartToursContingent contingent;

    /**
     *
     * This is the main
     */
    public static void main(String argv[]) {
        SmartToursClient client = new SmartToursClient();
        client.getInfo();
    }

    /**
     *
     * This is the standard constructor
     */
    public SmartToursClient() {
        try {
            Properties properties = new Properties();
            properties.put("org.omg.CORBA.ORBInitialHost", "localhost");//devdisapp.dynalias.org");
            InitialContext ic = new InitialContext(properties); //create context connected to server
            contingent = (SmartToursContingent) ic.lookup("grp02/SmartToursContingentBean"); //get proxz to the SmartToursCOntingentBean instance
            contingent.initialize(42, 21, "TAName");
        } catch (NamingException ex) {
            System.out.println("Bad name given for the server or object: " + ex.getMessage());
            System.exit(0);
        }
    }

    /**
     *
     * This is to get information about the booked type of room and where it is
     * booked printed out at the console
     */
    public void getInfo() {
        System.out.println("Single Booked Room : " + contingent.getSingleBookedRoom() + "\n"
                + "Family Booked Room : " + contingent.getFamilyBookedRoom() + "\n"
                + "Travel Agency Name : " + contingent.getTravelAgencyName());
    }
}
